<%--
  Created by IntelliJ IDEA.
  User: lenovo
  Date: 2019/9/29
  Time: 9:54
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>Title</title>
</head>
<body>

<div  class="container" >
    <div class="row" style="margin-top: 50px;text-align: center ;">
    <ul class="pagination ">
        <li><a onclick="goPage(1)">首页</a></li>

        <c:if test="${CommonPage.pageNum>1}">
            <li><a onclick="goPage(${CommonPage.pageNum-1})">&laquo;</a></li>
        </c:if>
        <%--不让点击--%>
        <c:if test="${CommonPage.pageNum<=1}">
            <li class="disabled"><a>&laquo;</a></li>
        </c:if>

        <%--循环标签  显示五个
        思路 -  起使值 - 从当前页高亮显示--%>
        <%--正常情况--%>


        <c:if test="${CommonPage.pageNum+2<CommonPage.pages}">
            <c:set var="startPage" value="${CommonPage.pageNum}"></c:set>
        </c:if>
        <%--尾部时候,起使页不变--%>
        <c:if test="${CommonPage.pageNum+2>=CommonPage.pages}">
            <c:set var="startPage" value="${CommonPage.pages-4}"></c:set>
        </c:if>

        <c:forEach begin="${startPage<=0?1:startPage}" end="${startPage+4}" var="n">
            <%--判断当前页是否高亮显示--%>
            <li <c:if test="${CommonPage.pageNum == n}">class='active'</c:if>>
                <a onclick="goPage(${n})">${n}</a>
            </li>

        </c:forEach>

        <%--下一页--%>
        <c:if test="${CommonPage.pageNum<CommonPage.pages}">
            <li><a  onclick="goPage(${CommonPage.pageNum+1})" >&raquo;</a></li>
        </c:if>
        <c:if test="${CommonPage.pageNum>=CommonPage.pages}">
            <li class="disabled"><a>&raquo;</a></li>
        </c:if>

        <li><a onclick="goPage(${CommonPage.pages})">尾页</a></li>

        <li><a href="#">当前页${CommonPage.pageNum}/${CommonPage.pages}总页</a></li>

    </ul>
    </div></div>
<script>

    //下一页
    function goPage(pageNum){
        $("#commonsPage").load("${path}/guide/getpage/"+${CommonPage.list[0].guideId},{pageNum:pageNum});
    }

</script>
</body>
</html>
